const path=require("path");

//假设一个文件的存放路径
const pathStr1="/a/b/c/index.html";
const pathStr2="/NODE-JS/day1/test.txt";

//通过path.basename()方法获取文件名
const pathStr1BaseName=path.basename(pathStr1);
const pathStr2BaseName=path.basename(pathStr2);
console.log(pathStr1BaseName);
console.log("^^^^^^");
console.log(pathStr2BaseName);

//通过设定指定参数，移除文件的扩展名
const BaseNameWithouExt1=path.basename(pathStr1BaseName,".html");
const BaseNameWithouExt2=path.basename(pathStr2BaseName,".txt");
console.log(BaseNameWithouExt1);
console.log("^^^^^^");
console.log(BaseNameWithouExt2);

//